home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Subject: Re: New C Programmer Has
- X-Nntp-Posting-Host: golden.ripco.com
- Message-ID: <DLz0oJ.KJ6@rci.ripco.com>
- Sender: usenet@rci.ripco.com (Net News Admin)
- Organization: Ripco Internet BBS Chicago
- Date: Tue, 30 Jan 1996 01:41:07 GMT
- X-Ident-Sender: mambuhl
-
- tsyslo@oasis.novia.net (Tony Syslo)
- in <4ehpa3$6kl@nntp.novia.net> asks:
-
- > I have a question on C... why isn't this program working?!
-
- Because it isn't written in C.
-
- Clean this up in several stages:
- 1) declare name with some space allocated to it, instead of an
- uninitialized pointer.
- 2) lose the non-standard headers <clib/dos_protos.h>, <dos/dos.h>,
- <exec/types.h>. Learn to use the standard libraries.
- 3) lose the useless and wrong prototype of main
- 4) remember that main returns an int. Declare it so.
- 5) rewrite the use of the non-standard functions (whatever they are)
- Open() /* use fopen() */
- Close() /* use fclose() */
- Write() /* use fwrite() */
- Read() /* use fread() */
- Seek() /* use fseek() */
- Exit() /* use exit() */
- 6) lose the non-standard struct FileHandle *. The standard way to
- access files is through FILE *s.
- 7) get the FAQ from rtfm.mit.edu and read it. Pay attention to the
- suggestions on alternatives to scanf() and gets().
- 8) don't assign strings to char *s in the body of the code.
- 9) don't use non-terminated strings as in:
- printf("Hello, %s!\",name);
-
- > Also, is there any of you whom might have a routine to figure up random (or
- > even psuedo-random) numbers?? Some algorithm, or such, as I need one BADLY!!
-
- 10) Try using the standard functions rand() and srand(). Once again,
- the FAQ will be of use. Why are you using all this non-standard
- crap when you don't seem to have a clue what the standard libraries
- contain?
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-